<template>
  <div class="waiting-info">
    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">区域设置</el-divider>
      </div>
      <el-form-item label="展示行数">
        <el-input-number
            :min="4"
            :max="6"
            v-model="optionsInfo.showRowNums"
            class="hide-spin-button"
            size="small"
            @change="handleTotal"
        />
      </el-form-item>
      <el-form-item label="行高">
        <el-input-number
            v-model="optionsInfo.lineHeight"
            :min="0"
            size="small"
            class="hide-spin-button"
        />
      </el-form-item>
      <el-form-item label="内容高度">
        <el-input-number
            v-model="optionsInfo.contentHeight"
            :min="0"
            size="small"
            class="hide-spin-button"
        />
      </el-form-item>
    </div>

    <div class="list-item-setting">
      <el-divider content-position="left">呼叫患者弹层显示</el-divider>
      <el-form-item label="设置显示" class="call-patient-set">
        <el-checkbox-group
            v-if="callPatientOptions&&callPatientOptions.length"
            v-model="optionsInfo.checkList">
          <el-checkbox
              v-for="item in callPatientOptions"
              :label="item.value"
              :key="item.value"
              :disabled="item.value===3"
              @change="(e)=>handleChange(e, item)"
          >
            {{ item.label }}
          </el-checkbox>
        </el-checkbox-group>
      </el-form-item>
    </div>


    <div class="list-title-setting">
      <div class="title-info">
        <el-divider content-position="left">列表头部设置</el-divider>
      </div>

      <el-form-item label="是否显示">
        <el-switch v-model="optionsInfo.headShow"/>
      </el-form-item>
      <el-form-item label="背景颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo.headerBackgroundColor"/>
      </el-form-item>
      <el-form-item label="字体颜色">
        <el-color-picker
            size="small"
            show-alpha
            :predefine="predefineColors"
            v-model="optionsInfo.headerFontColor"/>
      </el-form-item>
      <el-form-item label="高度">
        <el-input-number
            :min="0"
            size="small"
            class="hide-spin-button"
            v-model="optionsInfo.headHeight"
        />
      </el-form-item>
      <el-form-item class="col-info">
        <div class="title">
          <el-divider content-position="center">显示列</el-divider>
        </div>
        <div class="options-info">
          <el-checkbox-group v-model="optionsInfo.defaultShowCol">
            <Draggable
                class="list-group"
                @end="handleDragEnd"
                :list="(optionsInfo.colOptions)"
                :animation="100"
            >
              <el-checkbox
                  :label="item.value"
                  v-for="(item,index) in (optionsInfo.colOptions)"
                  :key="index"
                  :disabled="isDisabled(item.value)"
              >
                <el-input v-model="item.label" placeholder="请输入内容" size="small"/>
                <i class="el-icon-thumb"></i>
              </el-checkbox>
            </Draggable>
          </el-checkbox-group>
        </div>
      </el-form-item>


      <el-form-item class="register-info" v-if="(optionsInfo.defaultShowCol).includes('registerObjNames')">
        <div class="title">
          <el-divider content-position="center">号别类型</el-divider>
        </div>
        <div class="options-info">
          <el-radio-group v-model="optionsInfo.registerObjNameKey">
            <el-radio
                :label="item.dictValue"
                :value="item.dictValue"
                :key="item.dictValue"
                v-for="item in registerObjNameOptions"
            >
              {{item.dictLabel}}
            </el-radio>
          </el-radio-group>
        </div>
      </el-form-item>
    </div>

    <div class="list-item-setting">
      <div class="title-info">
        <el-divider content-position="left">诊室设置</el-divider>
      </div>
      <div>
        <roomNameKeyEditor
            businessType="special"
            :designer="designer"
            :selected-widget="selectedWidget"
            :option-model="optionModel"
        />
      </div>
    </div>

    <div class="list-scroll-setting">
      <div class="title-info">
        <el-divider content-position="left">列表设置</el-divider>
      </div>

      <el-form-item label="候诊类型设置" class="wait-patient-set">
        <el-radio-group v-model="optionsInfo.waitPatientType">
          <el-radio :label="item.value" v-for="item in waitPatientTypeOptions" :key="item.value">
            {{ item.label }}
          </el-radio>
        </el-radio-group>
      </el-form-item>

      <el-form-item label="子元素背景">
        <el-switch v-model="optionsInfo.itemShadow"/>
      </el-form-item>

      <el-form-item label="开启滚动" v-if="false">
        <el-switch v-model="optionsInfo.openScroll"/>
      </el-form-item>
      <el-form-item label="滚动速度" v-if="false">
        <el-input-number
            v-model="optionsInfo.scrollStep"
            :min="0"
            :max="4"
            :disabled="!(optionsInfo.openScroll)"
            size="small"
            class="hide-spin-button"
        />
      </el-form-item>
      <el-form-item label="是否切屏" v-if="false">
        <el-switch v-model="optionsInfo.switchScreen"></el-switch>
      </el-form-item>
      <el-form-item label="切屏时间(s)" class="switching-screen">
        <el-input-number
            :min="10"
            :step="1"
            size="small"
            class="hide-spin-button"
            v-model="optionsInfo.switchTime"
            :disabled="!(optionsInfo.switchScreen)"
        />
      </el-form-item>
    </div>

    <!--等待就诊滚动设置-->
    <div class="wait-visit-setting">
      <div class="title-info">
        <el-divider content-position="left">等待就诊</el-divider>
      </div>
      <el-form-item label="开启滚动">
        <el-switch v-model="optionsInfo.openScroll"/>
      </el-form-item>

      <el-form-item label="开启滚动数量">
        <el-input-number
            :min="0"
            :max="8"
            size="small"
            class="hide-spin-button"
            :disabled="!(optionsInfo.openScroll)"
            v-model="optionsInfo.waitingNumber"
        />
      </el-form-item>
      <el-form-item label="滚动速度">
        <el-input-number
            :min="1"
            :max="5"
            size="small"
            class="hide-spin-button"
            :disabled="!(optionsInfo.openScroll)"
            v-model="optionsInfo.waitingVisitStep"
        />
      </el-form-item>
      <el-form-item label="滚动方向" v-if="false">
        <el-radio-group
            size="small"
            :disabled="!(optionsInfo.openScroll)"
            v-model="optionsInfo.waitingVisitDirection"
        >
          <el-radio label="up">上下</el-radio>
          <el-radio label="left">左右</el-radio>
        </el-radio-group>
      </el-form-item>
    </div>

  </div>
</template>

<script>
import constantDic from "@/utils/vue-i18n/lang/zh-CN";
import Draggable from "vuedraggable"
import roomNameKeyEditor
  from "@sc/templateDetails/modules/homeRight/property-editor/module/scene-edit/basicInfo/roomNameKey-editor.vue";
import * as types from "@c/public/form-designer/devType/datas-types";

export default {
  name: "waitingDualQueueInfoConfig-editor",

  componentName: "waitingInfoConfig-editor",

  components: {
    roomNameKeyEditor,
    Draggable
  },

  mixins: [],

  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },

  inject: ['serverFieldList', 'getDesignerConfig'],

  data() {
    return {
      constantDic: constantDic,
      optionsInfo:Object(),
      predefineColors: types['predefineColors'],
      waitPatientTypeOptions:types['waitPatientTypeOptions'],
      callPatientOptions: [
        {
          value: 1,
          label: '科室'
        },
        {
          value: 2,
          label: '号别'
        },
        {
          value: 3,
          label: '诊室'
        }
      ],
    }
  },

  computed: {
    isDisabled() {
      return function (val) {
        // let arr = ['deptName', 'treatmentRoomName', 'workerName'];
        let arr = [];
        return arr.includes(val);
      }
    },

    registerObjNameOptions(){
      return this.$store.getters['templateDetails/getRegisterObjNameOptions']
    }
  },

  methods: {
    handleDragEnd() {},

    handleTotal(val){
      let {multiple} = (this.optionModel.waitingDualQueueInfoConfig)
      this.optionModel.rowNumber = multiple*val;
      console.log(this.optionModel);
    },


    // 科室诊室&号别--科室和好别不能共存
    handleChange(val, row) {
      let value = (row.value);
      let {checkList} = (this.optionModel.waitingDualQueueInfoConfig);
      if (value === 1) {
        if (val) {
          this.$lodash.pull(checkList, 2);
        }
      }
      if (value === 2) {
        if (val) {
          this.$lodash.pull(checkList, 1);
        }
      }
    },

  },

  watch: {
    // 组件的所有信息
    optionModel: {
      handler: function (val) {
        let key = val.config;
        this.optionsInfo = val[key];
      },
      deep: true,
      immediate: true
    }
  }

}
</script>

<style lang="scss" scoped>
.switching-screen{
  ::v-deep .el-input-number__decrease{
    margin-top: 1px;
  }
  ::v-deep .el-input-number__increase{
    margin-top: 1px;
  }
}

.call-patient-set{
  display: flex;
  flex-direction: column;
  :deep(.el-form-item__label){
    @include fontWeight();
    width: 100% !important;
  }
  :deep(.el-form-item__content){
    margin-left: 0 !important;
    .el-checkbox-group{
      display: flex;
      flex-direction: column;
    }
  }

}

.col-info {

  ::v-deep .el-form-item__content {
    margin-left: 1px !important;

    .title {
      width: 100%;
    }

    .el-checkbox__label {
      width: auto;
    }



    .el-icon-thumb{
      position: relative;
      top: 8px;
      padding-left: 10px;
      font-size: 18px;
      text-align: center;
    }

    .el-checkbox {
      width: calc(100% - 32px);
    }
  }

}
//号别简称
.register-info{
  :deep(.el-form-item__content) {
    margin-left: 1px !important;

    .title {
      width: 100%;
    }
    .el-radio-group{
      .el-radio{
        width: 100%;
        padding: 8px 0;
      }
    }
  }
}

.wait-patient-set {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    width: 100% !important;
  }

  :deep(.el-form-item__content) {
    margin-left: 0 !important;;

    .el-radio-group {
      display: flex;
      flex-direction: column;

      .el-radio {
        padding: 10px 0;
      }
    }
  }

}
</style>